export default function useColumns(props) {
  const columns = computed(() => {
    let list = [];
    props.columns.forEach((item) => {
      const { title, dataIndex, slotName, render, renderHtml, ...reset } = item;

      let itemProps = {
        ...reset,
        label: title,
      };

      if (slotName) {
        itemProps.slotName = itemProps;
      } else if (render) {
        itemProps.render = render;
      } else if (renderHtml) {
        itemProps.renderHtml = renderHtml;
      } else {
        itemProps.prop = dataIndex;
      }

      list.push(itemProps);
    });

    return list;
  });

  return {
    columnList: columns,
  };
}
